package com.solution.admin.customer.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.solution.admin.customer.dao.CompanyExpressConfigDao;
import com.solution.admin.customer.entity.CompanyExpressConfigEntity;
import com.solution.common.dao.impl.BaseDaoImpl;
import com.solution.common.page.PageBean;
import com.solution.common.page.PageParam;

/**
 * 公司常用物流配置DAO实现
 * @author solin
 * @date 2018-03-22 18:49:13
 */
@Repository
public class CompanyExpressConfigDaoImpl extends BaseDaoImpl<CompanyExpressConfigEntity> implements CompanyExpressConfigDao {
	
	@Autowired
	SqlSessionTemplate sqlSessionTemplate;

	/**
	 * 保存公司常用物流配置信息
	 * @param companyExpressConfigEntity
	 * @return
	 * @author solin
	 * @date 2018-03-22 18:49:13
	 */
	@Override
	public long saveCompanyExpressConfig(CompanyExpressConfigEntity companyExpressConfigEntity) {
		return super.insert(companyExpressConfigEntity);
	}
	
	
	@Override
	public long saveCompanyExpressConfig(List<CompanyExpressConfigEntity> companyExpressConfigEntitys) {
		return super.insert(companyExpressConfigEntitys);
	}

	/**
	 * 分页查询公司常用物流配置信息
	 * @param pageParam 分页对象
	 * @param companyExpressConfig 分页参数
	 * @return PageBean 分页参数及数据
	 * @author solin
	 * @date 2018-03-22 18:49:13
	 */
	public PageBean listCompanyExpressConfigPage(PageParam pageParam, Map<String, Object> param) {
		return super.listPage(pageParam, param);
	}

	/**
	 * 更新公司常用物流配置
	 * @param companyExpressConfigEntity
	 * @return
	 * @author solin
	 * @date 2018-03-22 18:49:13
	 */
	@Override
	public int updateCompanyExpressConfig(CompanyExpressConfigEntity companyExpressConfigEntity) {
		return super.update(companyExpressConfigEntity);
	}

	/**
	 * 删除公司常用物流配置
	 * @param companyExpressConfigId
	 * @return
	 * @author solin
	 * @date 2018-03-22 18:49:13
	 */
	public int deleteCompanyExpressConfigById( Long id) {
		return super.deleteById(id);
	}
	
	public int deleteCompanyExpressConfigByCompanyId( Long companyId) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("companyId", companyId);
		return sqlSessionTemplate.delete("deleteCompanyExpressConfigByCompanyId", companyId);
	}
	
	/**
	 * 根据条件查询公司常用物流配置
	 * @param param
	 * @return
	 * @author solin
	 * @date 2018-03-22 18:49:13
	 */
	@Override
	public List<CompanyExpressConfigEntity> listCompanyExpressConfig( Map<String, Object> param) {
		return super.listBy(param);
	}
}
